<body>
<div class="layui-fluid">
	<div class="layui-row layui-col-space15">
		<div class="layui-col-md12">
			<div class="layui-card">
				<div class="layui-card-header">{$page_name}</div>
				<div class="layui-card-body" pad15>
<form action="{:url(request()->action())}" method="post">
					<div class="layui-form">
						<div class="layui-form-item">
							<label class="layui-form-label">栏目名</label>
							<div class="layui-input-inline">
								<input type="text" class="layui-input" name="cat_name" autocomplete="off" value="{$info.cat_name}" lay-verify="required" placeholder="请输入栏目名">
							</div>
							<div class="layui-form-mid layui-word-aux"></div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">栏目英文名</label>
							<div class="layui-input-inline">
								<input type="text" class="layui-input" name="cate_name" autocomplete="off" value="{$info.cate_name}" placeholder="请输入栏目英文名">
							</div>
							<div class="layui-form-mid layui-word-aux"></div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">父级栏目</label>
							<div class="layui-input-inline" >
								<select name="up_id" lay-filter="up_id">
									<option value="0">--顶级--</option>
									{volist name="cat_list" id="vo"}
										<option value="{$vo.id}" {if $info.up_id == $vo.id} selected {/if} {if in_array($info['id'],$vo['path_arr']) && $info['id']!=0 } disabled {/if}>{$vo.name|raw}</option>
									{/volist}
								</select>
							</div>
							<div class="layui-form-mid layui-word-aux"></div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">栏目类型</label>
							<div class="layui-input-inline" >
								<select name="type" lay-filter="type">
									{volist name="content_type" id="vo"}
										<option value="{$vo.id}" {if $info.type == $vo.id} selected {/if}>{$vo.name}</option>
									{/volist}
								</select>
							</div>
							<div class="layui-form-mid layui-word-aux"></div>
						</div>

						<div class="layui-form-item" id="table_id" style="display:none;">
							<label class="layui-form-label">数据模型</label>
							<div class="layui-input-inline" >
								<select name="table_id" lay-filter="table_id">
									{volist name="content_table" id="vo"}
										<option value="{$vo.id}" {if $info.table_id == $vo.id} selected {/if} data-tpl='{category_tpl:"{$vo.category_tpl}",lists_tpl:"{$vo.lists_tpl}",show_tpl:"{$vo.show_tpl}"}'>{$vo.name}</option>
									{/volist}
								</select>
							</div>
							<div class="layui-form-mid layui-word-aux"></div>
						</div>

						<div class="layui-form-item" id="route" style="display:none;">
							<label class="layui-form-label">伪静态标识</label>
							<div class="layui-input-inline">
								<input type="text" class="layui-input" name="route" autocomplete="off" value="{$info.route}" lay-verify="route" placeholder="请输入伪静态标识">
							</div>
						</div>
						<div class="layui-form-item" id="url" style="display:none;">
							<label class="layui-form-label">外链</label>
							<div class="layui-input-inline">
								<input type="text" class="layui-input" name="url" autocomplete="off" value="{$info.url}" lay-verify="" placeholder="请输入外链">
							</div>
							<div class="layui-form-mid layui-word-aux">请输入跳转地址，1.本站相对地址以“/”开始；2绝对地址以https、http开始；3.留空。</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">排序</label>
							<div class="layui-input-inline">
								<input type="text" class="layui-input" name="sort" autocomplete="off" value="{$info.sort}" lay-verify="required|number" placeholder="请输入排序">
							</div>
						</div>

						<fieldset class="layui-elem-field" id="tpl_id" style="display:none;">
							<legend>模板</legend>
							<div class="layui-field-box">

								<div class="layui-form-item" id="category_tpl" style="display:none;">
									<label class="layui-form-label">栏目模板</label>
									<div class="layui-input-inline">
										<input type="text" class="layui-input" name="category_tpl" autocomplete="off" value="{$info.category_tpl}" lay-verify="" placeholder="请输入栏目模板">
									</div>
								</div>

								<div class="layui-form-item" id="lists_tpl" style="display:none;">
									<label class="layui-form-label">列表模板</label>
									<div class="layui-input-inline">
										<input type="text" class="layui-input" name="lists_tpl" autocomplete="off" value="{$info.lists_tpl}" old_val="{$info.lists_tpl}" lay-verify="" placeholder="请输入列表模板">
									</div>
								</div>

								<div class="layui-form-item" id="show_tpl" style="display:none;">
									<label class="layui-form-label">详情模板</label>
									<div class="layui-input-inline">
										<input type="text" class="layui-input" name="show_tpl" autocomplete="off" value="{$info.show_tpl}" old_val="{$info.show_tpl}" lay-verify="" placeholder="请输入详情模板">
									</div>
								</div>

								<div class="layui-form-item" id="content_tpl" style="display:none;">
									<label class="layui-form-label">单页模板</label>
									<div class="layui-input-inline">
										<input type="text" class="layui-input" name="content_tpl" autocomplete="off" value="{$info.content_tpl}" lay-verify="" placeholder="请输入单页模板">
									</div>
								</div>
							</div>
						</fieldset>

						<div class="layui-form-item">
							<label class="layui-form-label">启用状态</label>
							<div class="layui-input-inline">
								<input type="radio" name="status" value="1" title="开启" {if $info.status == 1} checked {/if}>
								<input type="radio" name="status" value="0" title="关闭" {if $info.status == 0} checked {/if}>
							</div>
						</div>

						<div class="layui-form-item">
							<div class="layui-input-block">
								<input name="id" type="hidden" value="{$info.id}">
								<button class="layui-btn"
									lay-submit
									lay-filter="wy-submit"
									wy-changetabid="contentcat_index"
									wy-closetabid="contentcat_info"
									wy-reloadpage="1"
								>确认提交</button>
								<button type="reset" class="layui-btn layui-btn-primary">重新填写</button>
							</div>
						</div>
					</div>
</form>
				</div>
			</div>
		</div>
	</div>
</div>
<script>
layui.use('form', function(){
	var form = layui.form;
	form.on('select(type)', function(data){
		edit_show_html(data.value);
	});
	form.on('select(table_id)', function(data){
		edit_tabl_tpl(data.value);
	});
});
edit_tabl_tpl($("select[name='table_id']").find("option:selected").val());
function edit_tabl_tpl(_val){
	var data = $("select[name='table_id']").find("option[value='"+_val+"']").attr('data-tpl');

	var data_json = eval('(' + data + ')');
	if($("input[name='lists_tpl']").val() != $("input[name='lists_tpl']").attr('old_val') || !$("input[name='lists_tpl']").val()){
		$("input[name='lists_tpl']").val(data_json.lists_tpl);
	}
	if($("input[name='show_tpl']").val() != $("input[name='show_tpl']").attr('old_val') || !$("input[name='show_tpl']").val()){
		$("input[name='show_tpl']").val(data_json.show_tpl);
	}
}
edit_show_html("{$info.type}");
function edit_show_html(_val){
	var _val = _val || '';
	if(_val == '0'){

		$("#route").hide();
		$("#url").show();

	}else if(_val == '1' || _val == '2' ||  _val == '3'){

		$("#route").show();
		$("#url").hide();

	}else{

		$("#route").hide();
		$("#url").hide();

	}

	switch(_val){
	    case '1':

	    	$("#table_id").show();
	    	$("#tpl_id").show();
			$("#category_tpl").hide();
			$("#lists_tpl").show();
			$("#show_tpl").show();
			$("#content_tpl").hide();

	        break;
	    case '2':

	    	$("#table_id").hide();
	    	$("#tpl_id").show();
			$("#category_tpl").hide();
			$("#lists_tpl").hide();
			$("#show_tpl").hide();
			$("#content_tpl").show();

	        break;
	    case '3':

	    	$("#table_id").show();
	    	$("#tpl_id").show();
			$("#category_tpl").show();
			$("#lists_tpl").hide();
			$("#show_tpl").hide();
			$("#content_tpl").hide();

	        break;
	    default:

	    	$("#table_id").hide();
	    	$("#tpl_id").hide();
	        $("#category_tpl").hide();
			$("#lists_tpl").hide();
			$("#show_tpl").hide();
			$("#content_tpl").hide();
	}


}
</script>
</body>